package com.ftg.learn;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.junit.Test;

import java.nio.file.Paths;

/**
 * @author 布衣
 */

public class GenCode {

    @Test
    public void genCodePlus() {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/java72", "root", "123456")
                .globalConfig(builder -> builder
                        .author("布衣")
                        .outputDir(Paths.get(System.getProperty("user.dir")) + "/src/main/java")
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.ftg.learn")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .addInclude("learn_student","sys_user") // 设置需要生成的表名
//                        .addTablePrefix("t_", "c_") // 设置过滤表前缀
                        .entityBuilder()
                        .enableLombok()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
